﻿Shader "Custom/BasicDiffuse" {  
    Properties {  
		//声明变量，在Inspector界面可修改
		_EmissiveColor("Emissive Color",Color)=(1,1,1,1)
		_AmbientColor  ("Ambient Color", Color) = (1,1,1,1)  
		_MySliderValue ("This is a Slider", Range(0, 10)) = 2.5 
    }  
    SubShader {  
        Tags { "RenderType"="Opaque" }  
        LOD 200  
          
        CGPROGRAM  
        #pragma surface surf Lambert  
		//声明一个和Properties中名字相同的变量，这将自动建立一个连接，两者将操作同一个数据。
        float4 _EmissiveColor;  
        float4 _AmbientColor;  
        float _MySliderValue;   
  
        struct Input {  
            float2 uv_MainTex;  
        };  
  
        void surf (Input IN, inout SurfaceOutput o) {  
            float4 c;
			//http://developer.download.nvidia.com/CgTutorial/cg_tutorial_appendix_e.html  //CG内置函数
			c = pow((_EmissiveColor+_AmbientColor),_MySliderValue);
			o.Albedo = c.rgb;
			o.Alpha = c.a;
        }  
        ENDCG  
    }   
    FallBack "Diffuse"  
}  